package micro.beauty.common.mybatis;
/**
* @Description:    分页基本数据
* @Author:         Liuliya
* @CreateDate:     2020/9/16 23:01
* @Version:        0.0.1
*/
public class PageQuery {
    /**
     * 当前页
     */
    private Integer current;
    /**
     * 每页数据量
     */
    private Integer size;
    /**
     * 升序条件列名
     */
    private String[] ascs;
    /**
     * 降序条件列名
     */
    private String[] descs;

    public PageQuery(Builder builder) {
        this.current = builder.current;
        this.size = builder.size;
        this.ascs = builder.ascs;
        this.descs = builder.descs;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private Integer current;
        private Integer size;
        private String[] ascs;
        private String[] descs;

        public Builder current(Integer current) {
            this.current = current;
            return this;
        }

        public Builder size(Integer size) {
            this.size = size;
            return this;
        }

        public Builder ascs(String... ascs) {
            this.ascs = ascs;
            return this;
        }

        public Builder descs(String... descs) {
            this.descs = descs;
            return this;
        }

        public PageQuery build() {
            return new PageQuery(this);
        }
    }

    public Integer getCurrent() {
        if (null == current) {
            current = 1;
        }
        return current;
    }

    public void setCurrent(Integer current) {
        this.current = current;
    }

    public Integer getSize() {
        if (null == size) {
            size = 20;
        }
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public String[] getAscs() {
        return ascs;
    }

    public void setAscs(String[] ascs) {
        this.ascs = ascs;
    }

    public String[] getDescs() {
        return descs;
    }

    public void setDescs(String[] descs) {
        this.descs = descs;
    }
}
